<template>
    <el-container class="applet">
        <el-main class="wrapper">
            <section class="panel cms-content">
                <div class="panel-body">
                    <div class="btn-group" style="margin-bottom: 15px">
                        <el-button @click="list" type="primary" icon="fa fa-refresh"
                                   size="small"> 刷新
                        </el-button>
                    </div>
                    <el-table v-loading="loading"
                              element-loading-text="努力加载中..."
                              element-loading-spinner="el-icon-loading"
                              :data="listData.data" :border="true" style="width: 100%">
                        <el-table-column prop="title" label="模板标题" width="250px"></el-table-column>
                        <el-table-column prop="template_id" label="模板ID" width="450px"></el-table-column>
                        <el-table-column prop="number" label="发送条数" width="100px"></el-table-column>
                        <el-table-column prop="success_number" label="成功条数" width="100px"></el-table-column>
                        <el-table-column prop="faild_number" label="失败条数" width="100px"></el-table-column>
                        <el-table-column prop="start_at" label="开始时间">
                            <template slot-scope="scope">{{ scope.row.start_at }}</template>
                        </el-table-column>
                        <el-table-column prop="end_at" label="结束时间">
                            <template slot-scope="scope">{{ scope.row.end_at }}</template>
                        </el-table-column>
                    </el-table>
                    <pagination :pageData="listData" :params="params" @list="list"/>
                </div>
            </section>
        </el-main>
    </el-container>
</template>
<script>
    import {mapGetters} from 'vuex';
    import Pagination from '@/components/pagination.vue';
    import {MessageRecord} from '../../utils/request';
    export default {
        components: {Pagination},
        data() {
            return {
                params: {page:1,applet:"aishenghuo"},
                listData: [],//列表数据
            }
        },
        activated() {
            this.$store.dispatch('setAiShengHuoActive', '/aishenghuo/record');
            this.list();
        },
        computed: {
            ...mapGetters(['loading']),
        },
        methods: {
            list() {
                this.$store.dispatch('setLoading', true);
                MessageRecord({params: this.params}).then((response) => {
                    if (response.code) {
                        this.$message.error(response.msg);
                    } else {
                        this.$store.dispatch('setLoading', false);
                        this.listData = response.data;
                    }
                })
            },
        },
    }
</script>
